<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    canvas{
      border: 1px solid #ccc;
      /* width: 600px;
      height: 400px; */
    }
  </style>
</head>
<body>
  <!-- 用canvas的属性来调整大小，坐标系不会变形 -->
  <canvas width="600" height="400"></canvas>
  <script>
    //获取画布
    let canvas=document.querySelector("canvas")
    // console.log(canvas)

    //获取一支笔
    let ctx=canvas.getContext("2d")

    //画一条直线
    ctx.strokeStyle="#ff0000"       //指定颜色
    ctx.moveTo(0,0)                  //抬起笔尖，移动到原点
    ctx.lineTo(100,0)               //绘制直线，结束位置
    ctx.stroke()                    //描边


    //绘制第二条线
    ctx.moveTo(100,100)
    ctx.lineTo(200,200)
    ctx.stroke()

    //绘制第三条线
    ctx.lineTo(300,100)
    ctx.stroke()






  </script>
</body>
</html>